import type { DepartData, OrderDetail, OrderParams, OrderPreData, OrderPreParams, PayParams, Picture } from "@/types/consult"
import { request } from "@/utils/http"

// 1. 获取科室
export const departmentListApi = () => request.get<null, DepartData[]>('/dep/all')

// 2. 上传图片
export const uploadImgApi = (file: File) => request.upload<null, Picture>('/upload', file)

// 3. 获取预支付订单信息
export const preOrderApi = (params: OrderPreParams) =>
  request.get<null, OrderPreData>('/patient/consult/order/pre', {
    params,
  })

// 4. 获取订单id
export const createOrderApi = (data: OrderParams) =>
  request.post<null, { id: string }>('/patient/consult/order', data)


// 5. 获取支付跳转地址
export const orderPayApi = (data: PayParams) => {
  return request.post<null, {payUrl:string}>('/patient/consult/pay', data)
}

// 6. 获取订单详情
export const orderDetailApi = (orderId: string) => {
  return request.get<null, OrderDetail>('/patient/consult/order/detail', { params: { orderId } })
}